<?php
/**
 * Created by PhpStorm.
 * User: sqq
 * Date: 2018/08/29
 * Time: 17:40
 */
$api_service_path = __DIR__ . "/../../../api/";
ob_start();
require_once($api_service_path . "public/index.php");
ob_end_clean();
DB::connection()->disableQueryLog();

//配置门店ID
$shop_id = 18;

//获取所有类型为公告的站内信
$sc_notice = ScNotice::where('status',1)->where('notice_type',1)->get();

//删除适配
$shop_notice = ScNoticeShop::where('shop_id',$shop_id)->where('status',1)->delete();

//适配门店
if(!is_null($sc_notice)){
    foreach($sc_notice as $key => $val){
        $shops = new ScNoticeShop();
        $shops->notice_id = $val->id;
        $shops->activity_base_id = $val->activity_base_id;
        $shops->shop_id = $shop_id;
        $shops->status = 1;
        $shops->created_at = Common::currentTimeString();
        $shops->updated_at = Common::currentTimeString();
        $shops->created_by = 1;
        try {
            $shops->save();
            Log::info($val->name." 已适配");
            echo $val->name." 已适配";
        } catch (Exception $e) {
            Log::error("error", array("system" => "api", "event" => "new_shop_synchra_notice", 'data' => $shops->toArray(), "exception" => $e));
        }
    }
}












